package com.lucker.common.util;

import java.util.Map;

import org.apache.commons.collections4.map.HashedMap;

import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.util.StringUtil;

import antlr.StringUtils;

public class JiSuDataUtil {
	
	private static final String appKey = "90cbf04efa0a1b26";
	private static String url = "";
	
	public static String getCaiPiaoList() throws Exception {
		url = "http://api.jisuapi.com/caipiao/class";
		Map<String,Object> jisuParamMap = new HashedMap<String,Object>();
		jisuParamMap.put("appkey", appKey);
		String json_result = HttpUtil.post(url, jisuParamMap);
		return json_result;
	}
	
	/**
	 * 
	 * @param caipiaoid 彩票ID
	 * @return  获取当前期的开奖号码
	 * @throws Exception
	 */
	public static String getOpenCaiPiaoInfo(String caipiaoid) throws Exception{
		return getOpenCaiPiaoInfo(caipiaoid,null);
	}
	
	/***
	 * 
	 * @param caipiaoid 彩票ID
	 * @param issueno 期号
	 * @return 获取指定期的开奖号码
	 * @throws Exception
	 */
	public static String getOpenCaiPiaoInfo(String caipiaoid,String issueno) throws Exception{
		url = "http://api.jisuapi.com/caipiao/query";
		Map<String,Object> jisuParamMap = new HashedMap<String,Object>();
		jisuParamMap.put("appkey", appKey);
		jisuParamMap.put("caipiaoid", caipiaoid);
		if(StringUtil.isNotEmpty(issueno)) {
			jisuParamMap.put("issueno", issueno);
		}
		String json_result = HttpUtil.post(url, jisuParamMap);
		return json_result;
	}
	
	
	
	/***
	 * 
	 * @param caipiaoid 彩票ID
	 * @param issueno  期号 (非必填项,传null 或 "" ,默认查询当前期的中奖号码)
	 * @param num  获取数量，默认10 最大20 (非必填项 默认10)
	 * @param start 起始位置 默认0 (非必填项 默认0)
	 * @return
	 * @throws Exception
	 */
	public static String getHistoryOpenCaiPiaoInfo(String caipiaoid,String issueno,int num,int start) throws Exception{
		url = "http://api.jisuapi.com/caipiao/history";
		Map<String,Object> jisuParamMap = new HashedMap<String,Object>();
		jisuParamMap.put("appkey", appKey);
		jisuParamMap.put("caipiaoid", caipiaoid);
		jisuParamMap.put("num", num);
		jisuParamMap.put("start", start);
		if(StringUtil.isNotEmpty(issueno)) {
			jisuParamMap.put("issueno", issueno);
		}
		String json_result = HttpUtil.post(url, jisuParamMap);
		return json_result;
		
	}
	
	
	
	
	
	
	
	
	
	public static void main(String[] args) {
		
		try {
			//getCaiPiaoList();
			
			//85
			getHistoryOpenCaiPiaoInfo("102",null,1,0);
			
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	

}
